package com.example.rabbitmq.demo1_delay;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author songyahui
 * @Date 2023/7/12 9:14
 * @Description
 */
@Configuration
public class TTlQueueOptimizeConfig {

    //普通队列-无ttl设置
    public static final String QUEUE_C = "QC";

    @Bean("queueC")
    public Queue queueC(){
        Map<String, Object> arguments = new HashMap<>();
        arguments.put("x-dead-letter-exchange", TtlQueueConfig.Y_DEAD_LETTER_EXCHANGE);
        arguments.put("x-dead-letter-routing-key", "YD");
        return QueueBuilder.durable(QUEUE_C).withArguments(arguments).build();
    }

    @Bean
    public Binding queueC_BindingX(@Qualifier("queueC") Queue queueC, @Qualifier("xExchange") DirectExchange x_exchange){
        return BindingBuilder.bind(queueC).to(x_exchange).with("XC");
    }
}
